<?php
/**
 * Created by PhpStorm.
 * User: czm
 * Date: 2019-07-24
 * Time: 13:45
 */
namespace app\index\controller;

use think\Controller;
use think\Db;

class User extends Controller
{
    public function userList()
    {
        $id = input('phone');
        $list = Db::name('user')->where('phone',$id)->find();
        if ($list){
            $dat = ['code' => 200, 'msg' => '成功'];
            return json_encode($dat);
        }else{
            $dat = ['code' => 403, 'msg' => '失败'];
            return json_encode($dat,TRUE);
        }
    }

    public function userEdit()
    {
        $id = input('post.');
        $a = $id['phone'];
        $ad = Db::name('user')->where('phone',$a)->find($a);
        if ($ad){
            $dat = ['code' => 438, 'msg' => '手机号不存在'];
            return json_encode($dat,TRUE);
        }
        if (request() -> isPost()){
            $b = input('post.');
            $bb = Db::name('user')->where('phone',$a)->update($b);
            if ($bb){
                $dat = ['code' => 200, 'msg' => '成功'];
                return json_encode($dat,TRUE);
            }else{
                $dat = ['code' => 403, 'msg' => '失败'];
                return json_encode($dat,TRUE);
            }
        }
    }
}